const paginationBev = Behavior({
  data: {
    dataArray: [],
    total: 0,
    noData: false
  },

  methods: {
    setMoreData: function (dataArray) {
      const tempArray = this.data.dataArray.concat(dataArray)
      this.setData({
        dataArray: tempArray
      })
    },

    getCurrenStart: function () {
      return this.data.dataArray.length
    },

    setTotal: function (total) {
      if(total == 0) {
        this.setData({
          noData: true
        })
      }
      this.data.total = total
    },

    hasMore: function () {
      if (this.data.dataArray.length >= this.data.total) {
        return false
      } else {
        return true
      }
    },

    initialize: function (){
      this.setData({
        dataArray: [],
        total: 0,
        noData: false
      })
    }

  }

})

export {paginationBev}
